<#include "layout/template.ftl"/>

<@htmlHead title="商户订单列表">
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${resources}/assets/css/jquery-ui.css" />
		<link rel="stylesheet" href="${resources}/assets/css/datepicker.css" />
		<link rel="stylesheet" href="${resources}/assets/css/ui.jqgrid.css" />
		<link rel="stylesheet" href="${resources}/plugins/jqgrid/4.6/jqgrid.extend.css" />
</@htmlHead>


 
<@htmlBody 'order' 'merchantorder'>

	<!-- breadcrumbs begin -->
	<#include "layout/breadcrumbs.ftl">
	<@breadcrumbs '商户订单管理' '商户订单列表'></@breadcrumbs>
	<!-- breadcrumbs start -->

	<!-- page-content begin -->
	<div class="page-content">
			
			<!-- page-header begin -->
			<div class="page-header">
				<h1>
					<i class="fa fa-trophy"></i>&nbsp;商户订单列表  
					
				<h1>
				
				<div style="margin-top:20px;padding:10px 0px 0px 0px;border-top:1px solid #307ecc">
					<div style="float:right">
						<button id="find_btn"  class="btn btn-sm btn-primary">
							<i class="ace-icon fa fa-search"></i>查 询
						</button>
						<button id="batchSend" name = "abc"  class="btn btn-danger btn-sm">
							<i class="ace-icon fa fa-search"></i>批量发货
						</button>
				    </div>
				    
				    <div id="query" class="query-view" style="">
						<ul class="list-inline">
							<li>	
					        	<label>会员手机:</label><input type="text" class="input" id="memberName" name="member.username" data-op="cn" /> 
							</li>
							<li>	
					        	<label>银行名称:</label><input type="text" class="input" id="corpname" name="corp.name" data-op="cn" /> 
							</li>
							<li>	
					        	<label>订单号:</label><input type="text" class="input" id="orderno" name="orderno" data-op="cn" /> 
							</li>
							<li>	
					        	<label>订单状态:</label>
					        	<select  id="status" name="status" data-op="eq"  class="input-sm" style="width:100px;">
					        		<option value="">全部</option>
					        		<#list  orderStatusEnum as enum>
					        			<option value="${enum.value}">${enum.comment}</option>
					        		</#list>
					        	</select>
					        	
							</li>
							
						</ul>
						
						<ul class="list-inline">
							<li>	
					        	<label>开始日期:</label><input type="text" class="input" id="starttime" name="createTime" data-op="ge" /> 
							</li>
							<li>	
					        	<label>结束日期:</label><input type="text" class="input" id="endtime" name="createTime" data-op="le" /> 
							</li>
						</ul>
					</div>
				</div>
			</div>
			<!-- page-header end -->
	
			
			
			<!-- jqGrid begin -->
			<div class="row">	
				<div class="col-md-12">	
				  	<table id="grid-table"></table>
			 		<div id="grid-pager"></div>
				</div>
			</div>	
			<!-- jqGrid end -->
	</div>		
	<!-- page-content end -->	


</@htmlBody>



<@htmlBodyScript>

		
		<!-- 日期控件-->
	 	<script src="${resources}/plugins/bootstrap-datetimepicker/2.3.4/js/bootstrap-datetimepicker.js"></script>
	   	<script src="${resources}/plugins/bootstrap-datetimepicker/2.3.4/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
		<script>
			$("#starttime,#endtime").datetimepicker({
				bootcssVer:3,
			    format: "yyyy-mm-dd",
			    language:"zh-CN",
				weekStart: 1,
	        	todayBtn:  1,
				autoclose: 1,
				todayHighlight: 1,
				startView: 2,
				minView: 2,
				forceParse: 0
			});
		</script>


		<!-- 格式化货币 -->
		<script src="${resources}/plugins/tool/accounting.min.js"></script>
		<script src="${resources}/assets/js/date-time/bootstrap-datepicker.js"></script>
		<script src="${resources}/assets/js/jqGrid/jquery.jqGrid.src.js"></script>
		<script src="${resources}/assets/js/jqGrid/i18n/grid.locale-cn.js"></script>

		<script>
			

			var grid_selector = "#grid-table";
			var pager_selector = "#grid-pager";
		    var $path ='${path}';

			$(function(){
				//----------------------jqgrid查询开始 ---------------------
				//分页插件开始
				$("#grid-table").jqGrid({
					url: '${path}/manage/order/merchantorder/list',
				 	mtype : "post", 
					datatype: "json",
					//prmNames : {search : "search"},  
					colNames:[ 'ID','会员手机','会员昵称','银行','订单号','支付方式','支付类型','支付时间','支付积分','支付金额','减免金额','订单状态','创建时间','备注','操作'],
				 	colModel: [
						{name:'id', width:30},
						{name:'member.username',width:50},
						{name:'member.nickname',width:50},
						{name:'corp.name',width:50},
						{name:'orderno',width:100},
						/*
						{
							name:'orderPlat.consigneeType', 
							width:75,
							formatter:function(cellValue, options, rowObject) {
								var output = "";
								if(cellValue==1){
									output="快递";
								}else if(cellValue==2){
									output="自提";
								}
								return output;
							}
						},
						*/
						{
							name:'orderPlat.paymentType', 
							width:75,
							formatter:function(cellValue, options, rowObject) {
								var output = "";
								if(cellValue==1){
									output="支付宝";
								}else if(cellValue==2){
									output="微信支付";
								}
								return output;
							}
						},
						
						{
							name:'orderPlat.paymode', 
							width:75,
							formatter:function(cellValue, options, rowObject) {
								var output = "";
								if(cellValue==1){
									output="现金";
								}else if(cellValue==2){
									output="积分";
								}
								return output;
							}
						},
						{
							name:'payTime', 
							width:75,
							formatter:function(cellValue, options, rowObject) {
								var output	='';
								if(cellValue!=null){
									var output = moment(cellValue).format('YYYY-MM-DD HH:mm:ss');
								}
								
								return output;
							}
						},
						{name:'score',width:50},
						{name:'total',width:50},
						{name:'subPrice',width:50},
						{
							name:'status', 
							width:50,
							formatter:function(cellValue, options, rowObject) {
				         		var option = '<div class="ui-status">';
								if(cellValue==1){
									option+= "<span class='label label-sm label-success'>未支付</span>";
								}else if(cellValue==2){
									option+= "<span class='label label-sm label-warning'>取消</span>";
								}else if(cellValue==3){
									option+= "<span class='label label-sm label-primary'>已支付</span>";
								}else if(cellValue==4){
									option+= "<span class='label label-sm label-pink'>已发货</span>";
								}else if(cellValue==5){
									option+= "<span class='label label-sm label-warning'>已签收</span>";
								}
								
								option = option +'</div>';      
			               		return option;
			        		}
						},
						{
							name:'createTime', 
							width:75,
							formatter:function(cellValue, options, rowObject) {
								var output = moment(cellValue).format('YYYY-MM-DD HH:mm:ss');
								return output;
							}
						},
						 {name:'remarks',width:50},
						{
							name:'id', 
							width: 100,
							formatter :function(cellvalue, options, rawObject) {
					    		var option = '<div class="ui-op">'; 
					    		
					    		option = option +'<a class="" data-toggle="tooltip" data-placement="bottom" title="详情"  href="${path}/manage/order/merchantorder/'+cellvalue+'">详情';
				                option = option +'</a>'; 
				                option = option +'<a class="" data-toggle="tooltip" data-placement="bottom" title="备注"  href="${path}/manage/order/merchantorder/remarks/'+cellvalue+'">备注';
				                option = option +'</a>'; 
				                if(rawObject.status==3){ 
					                option = option +'<a class="" data-toggle="tooltip" data-placement="bottom" title="发货"    href="${path}/manage/order/merchantorder/send/'+cellvalue+'"  >发货'; 
				                	option = option +'</a>';  
			                	}
			                	option = option +'<a class="" data-toggle="tooltip" data-placement="bottom" title="打印"  href="${path}/manage/order/merchantorder/print/'+cellvalue+'">打印';
				                option = option +'</a>'; 
								option = option +'</div>';      
			               		return option;  
							}
						}
					],
					viewrecords: true, 							// 在toolbar显示的当前页数,步长,总数
					autowidth: true,								//自动宽度
					height: "450",
					rowNum: 20,
					rowList:[20,50,100],
					sortname: 'id',
					sortorder: 'desc',
					pager: "#grid-pager",
					caption: "列表",
					multiselect : true,
					loadComplete : function() {
						var table = this;
						setTimeout(function(){
							styleCheckbox(table);
							updateActionIcons(table);
							updatePagerIcons(table);
							enableTooltips(table);
						}, 0);
					}
					
				});
				//分页插件结束
				
				//------------------------------- 自定义查询开始 -------------------------------
				//自定义查询开始
				$("#find_btn").click(function(){ 
					searchData('${path}/manage/order/merchantorder/list');
			    }); 
				//自定义查询结束
				
			})
		</script>	
	    <script src="${resources}/assets/js/jqGrid/jquery.jqGrid.Extract.js"></script>

 		<script>
		$("#batchSend").click(function(){
			var is=confirm("确定批量发货选中的订单么?");
			if(is==false){
				return false;
			}else{
				var ids=$("#grid-table").jqGrid('getGridParam','selarrrow');
				window.location.href="${path}/manage/order/merchantorder/batchSend?ids="+ids;
			}
		})
		</script>
</@htmlBodyScript>